package com.example.demonstrate.wang.config;

import com.example.demonstrate.wang.convert.ProfileMessageConverter;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.context.annotation.Configuration;

import java.util.Map;

@Configuration
@RefreshScope
public class ProfileMessageConfig {

    @Value("${message.version}")
    private String version;

    @Autowired
    private Map<String, ProfileMessageConverter> converters;

    public ProfileMessageConverter getConverter() {
        return converters.get(version);
    }
}
